Skip to content

🧹 [code health] Implement renderComponent component mounting#37

Open
Jeshua Ben Joseph (Theaxiom) wants to merge 2 commits intomainfrom
fix-render-component-mount-14696471798748370391
Open

🧹 [code health] Implement renderComponent component mounting#37
Jeshua Ben Joseph (Theaxiom) wants to merge 2 commits intomainfrom
fix-render-component-mount-14696471798748370391

Conversation

@Theaxiom
Copy link
Copy Markdown
Member

Replaced the TODO stub in renderComponent (fsl/test/src/mocks.fx) to correctly mount the component by casting it to a function and evaluating it with the provided props. Added a unit test in test.test.fx to verify correct rendering behavior.

Replaced the TODO stub in `renderComponent` (fsl/test/src/mocks.fx) to correctly mount the component by casting it to a function and evaluating it with the provided props. Added a unit test in `test.test.fx` to verify correct rendering behavior.

Co-authored-by: Theaxiom <57013+Theaxiom@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 30, 2026 00:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a first-pass renderComponent mounting behavior in the forge:test utilities and adds a self-test to validate basic DOM rendering via the test helper.

Changes:

  • Implement component mounting in renderComponent by invoking the provided component and appending the result to a container.
  • Add a new unit test covering renderComponent rendering output.
  • Update the self-test import list to include renderComponent.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
fsl/test/src/mocks.fx Replaces the renderComponent TODO with actual mounting logic (component invocation + DOM append).
fsl/test/tests/test.test.fx Adds a self-test verifying renderComponent renders expected text output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +32 to +42
describe('renderComponent', () => {
it('mounts a component and renders its output', async () => {
// Dummy component function mimicking compiled Forge output
const MyComponent = (props: { title?: string } = {}) => {
const el = document.createElement('div')
el.textContent = props.title ?? 'Hello World'
return el
}

const { getByText, unmount } = await renderComponent(MyComponent, { title: 'Test Component' })

Comment thread fsl/test/src/mocks.fx Outdated
Comment on lines +26 to +27
const componentFn = component as (props: Record<string, unknown>) => Element
const element = componentFn(props ?? {})
@Theaxiom
Copy link
Copy Markdown
Member Author

Copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

Copilot apply changes based on the comments in this thread

Done in 800984c.

renderComponent now handles both input shapes:

  • Pre-constructed Element — detected via instanceof Element, appended directly (props ignored)
  • Component function + props — called with props ?? {}, result appended
  • Anything else — throws TypeError: renderComponent: expected a component function or an Element, got <type>

Added a second test in test.test.fx that passes a raw <p> element with no props argument and asserts getByText finds the rendered text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants